<!--  -->
<template>
  <w-dialog :closeFree='true' @ok="submitOk" width="620px" title="取消文件授权" v-model="_value">
     <el-transfer v-model="traValue" :data="traData"  :titles="['已授权', '取消授权']"  filterable>
      <template #default="{ option }">
          <span>{{ option.label }}</span>
          <el-tag type="primary" style="margin-left: 4px;">{{option.tag}}</el-tag>
        </template>
      </el-transfer> 
  </w-dialog>
</template>

<style lang='scss' scoped></style>
<script>

// {
//   "createItemCloudParams": [
//     {
//       "authKey": "string",
//       "authType": 0,
//       "fileKey": "string"
//     }
//   ]
// }
import { getfliesAuthobject, removeFileAuth } from '@/api/fileManage.js';
export default {
  components: {},
  props:{
    modelValue: {
      type: Boolean,
      default: false,
    },
    cancelFileKey:{
      type: String,
      default: '',
    },
    isFloder: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      traValue: [],
      traData: []
    };
  },
  computed: {
    _value: {
      get() {
        return this.modelValue
      },
      set(val) {
        this.$emit('update:modelValue', val)
      },
    },
  },
  watch: {},
  methods: {
    submitOk(){
      console.log(this.traValue,1111)
      removeFileAuth({ authKeys: this.traValue,fileKey: this.cancelFileKey }).then(res => {
        if(res.data.success){
            this.$message.success('取消授权成功')
            this._value = false
          }
        })
    }
  },
  created() {
    getfliesAuthobject(this.cancelFileKey).then(res=>{
      if(res.data.success){
        this.traData = res.data.rows.map(i=>{
          return {
            key: i.authKey,
            label: i.authName,
            tag:i.isDownload?'下载':i.isRead?'仅预览':''
          }
        })
      }
    })
  },
  mounted() {

  },
  emits: ['update:modelValue']
}
</script>